#include <stdio.h>
#include <unistd.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <string.h>
#define IO_FILE(number) "io.txt"#number
int main()
{
    printf("stdin->fd:%d\n",stdin->_fileno);
    printf("stdout->fd:%d\n",stdout->_fileno);
    printf("stderr->fd:%d\n",stderr->_fileno);
    int fd0 =open(IO_FILE(1),O_WRONLY | O_CREAT,0666);
    int fd1 =open(IO_FILE(2),O_WRONLY | O_CREAT,0666);
    int fd2 =open(IO_FILE(3),O_WRONLY | O_CREAT,0666);
    int fd3 =open(IO_FILE(4), O_CREAT,0666);

    printf("fd0:%d \n",fd0);
    printf("fd1:%d \n",fd1);
    printf("fd2:%d \n",fd2);
    printf("fd3:%d \n",fd3);
    
    close(fd0);
    close(fd1);
    close(fd2);
    close(fd3);
    //umask(0);
    //int fd = open(IO_FILE , O_RDONLY);
    //if(fd<0)
    //{
    //    perror("open");
    //    return 1;
    //}
    //char buff[1024];
    //ssize_t num = read(fd,buff,sizeof(buff)-1);
    //if(num>0) buff[num]=0;
    //printf("%s",buff);

    ////char buff[64];
    ////int cnt = 5;
    ////while(cnt)
    ////{
    ////    sprintf(buff,"Hello IO:%d \n",cnt--);
    ////    write(fd,buff,strlen(buff));
    ////}
    //close(fd);
    return 0;
}
